package cn.edu.ncu.housinghub.constant;

import cn.edu.ncu.housinghub.exception.BusinessException;
import cn.edu.ncu.housinghub.vo.Result;
import lombok.Getter;

/**
 * 错误码常量枚举类
 */
@Getter
public enum ErrorCodeConstant {

    // 用户相关错误 1000-1999
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_ALREADY_EXISTS(1002, "用户已存在"),
    INVALID_CREDENTIALS(1003, "邮箱或密码错误"),
    EMAIL_ALREADY_EXISTS(1004, "该邮箱已被注册"),
    PASSWORD_MISMATCH(1005, "两次输入密码不一致"),
    USER_LOGIN_ERROR(1006, "用户登录错误"),
    USER_REGISTER_ERROR(1007, "用户注册错误"),
    USER_LOGOUT_ERROR(1008, "用户退出错误"),
    USER_AUTH_ERROR(1009, "用户认证错误"),
    USER_QUERY_ERROR(1010, "查询用户错误"),
    USER_SAVE_ERROR(1011, "保存用户错误"),
    USER_DONT_VERIFIED(1012, "用户未实名认证"),
    IDENTITY_VERIFICATION_ERROR(1013, "实名认证失败"),
    INVALID_TOKEN(1014, "无效的访问信息"),
    USER_HAS_OTHER_ROLE(1015, "用户已存在其他角色"),
    APPLY_ERROR(1016, "申请失败"),
    APPLY_ALREADY(1017, "已申请"),
    APPLY_HAS_BEEN_PROCESSED(1018, "该用户申请已处理"),
    LICENSE_ALREADY_APPLY(1019, "该房产证编号已被申请"),
    BUSINESS_LICENSE_ALREADY_APPLY(1020, "该营业执照编号已被申请"),
    USER_ALREADY_VERIFIED(1021, "用户已实名认证"),
    LANDLORD_INFO_NOT_MATCH(1022, "房东信息不匹配"),
    Agent_INFO_NOT_MATCH(1023, "中介信息不匹配"),
    USER_NOT_LOGIN(1024, "未登录"),
    USER_UPDATE_ERROR(1025, "更新用户信息失败"),
    INVALID_OLD_PASSWORD(1026, "原密码错误"),
    PASSWORD_CHANGE_ERROR(1027, "修改密码失败"),
    USER_ROLE_NOT_MATCH(1028, "用户角色不匹配"),
    AGENT_APPLY_NOT_FOUND(1029, "中介申请不存在"),

    // 管理员相关错误（5000-5999）
    ADMIN_LOGIN_FAILED(5000, "管理员账号或密码错误"),


    //房产相关错误（4000-4999）
    PROPERTY_VERIFICATION_NOT_PASSED(4001, "房产认证未通过"),
    PROPERTY_VERIFICATION_NOT_EXIST(4002, "房产认证不存在"),
    PROPERTY_VERIFICATION_EXIST(4003, "房产认证已存在"),
    PROPERTY_VERIFICATION_SAVE_ERROR(4004, "保存房产认证错误"),
    PROPERTY_OPERATION_NOT_AUTHORIZED(4005, "无权操作该房产"),
    PROPERTY_ALREADY_PUBLISHED(4006, "房产已发布"),
    PROPERTY_VERIFY_STATUS_MISMATCH(4008, "房产审核状态不匹配当前操作"),

    //合同相关错误（3000-3999）
    CONTRACT_NOT_EXIST(3001, "合同不存在"),
    CONTRACT_STATUS_MISMATCH(3002, "合同状态不匹配当前操作"),
    CONTRACT_OPERATION_NOT_AUTHORIZED(3003, "无权操作该合同"),

    //房源相关错误
    HOUSE_NOT_EXIST(5001, "房源不存在"),
    HOUSE_NOT_FOUND(5001, "房源不存在"),
    HOUSE_STATUS_MISMATCH(5002, "房源状态不匹配当前操作"),
    GET_HOUSE_DETAIL_ERROR(5003, "获取房源详情错误"),
    CREATE_APPOINTMENT_ERROR(5004, "创建预约错误"),
    HOUSE_ALREADY_AGENT(5005, "房源已被代理"),
    HOUSE_NOT_SUPPORT_AGENT(5006, "房源不支持中介代理"),
    APPOINTMENT_NOT_FOUND(5007, "预约不存在"),
    APPOINTMENT_ALREADY_HANDLED(5008, "预约已处理"),
    APPLICATION_NOT_FOUND(5009, "申请不存在"),
    APPLICATION_ALREADY_HANDLED(5010, "申请已处理"),

    // Token相关错误 2000-2999
    TOKEN_INVALID(2001, "访问信息无效或已过期"),
    TOKEN_MISSING(2002, "未提供访问信息"),
    TOKEN_GENERATE_ERROR(2003, "生成访问信息过程中发生错误"),
    TOKEN_DELETE_ERROR(2004, "删除访问信息过程中发生错误"),

    // 参数验证相关错误 3000-3999
    PARAM_VALIDATION_FAILED(3001, "参数验证失败"),
    PARAM_BIND_ERROR(3002, "参数绑定错误"),
    CONSTRAINT_VIOLATION_ERROR(3003, "约束违反错误"),
    FILE_UPLOAD_ERROR(3004, "文件上传错误,无效的文件格式"),
    FILE_UPLOAD_IMAGE_TYPE_ERROR(3005, "文件格式无效，请上传图片"),
    FILE_UPLOAD_IMAGE_TYPE(3006,"请上传图片文件（支持jpg、png、gif等格式）"),
    FILE_UPLOAD_PDF_TYPE_ERROR(3007, "文件格式无效，请上传PDF"),

    // 系统级别错误 9000-9999
    SYSTEM_ERROR(9001, "系统内部错误"),
    DATABASE_ERROR(9002, "数据库操作错误"),
    REDIS_ERROR(9003, "Redis操作错误"),
    NETWORK_ERROR(9004, "网络连接错误"),

    // 聊天相关错误 6000-6999
    CHAT_SESSION_CREATE_ERROR(6001, "创建会话失败"),
    CHAT_MESSAGE_SEND_ERROR(6002, "发送消息失败"),
    CHAT_SESSION_LIST_ERROR(6003, "获取会话列表失败"),
    CHAT_MESSAGE_HISTORY_ERROR(6004, "获取消息历史失败"),
    CHAT_MESSAGE_READ_ERROR(6005, "标记已读失败"),
    CHAT_UNREAD_COUNT_ERROR(6006, "获取未读数量失败"),
    CHAT_TOTAL_UNREAD_ERROR(6007, "获取总未读数量失败"),

    // 系统消息相关错误 7000-7999
    SYSTEM_MESSAGE_LIST_ERROR(7001, "获取系统消息失败"),
    SYSTEM_MESSAGE_READ_ERROR(7002, "标记已读失败"),
    SYSTEM_MESSAGE_BATCH_READ_ERROR(7003, "批量标记已读失败"),
    SYSTEM_MESSAGE_DELETE_ERROR(7004, "删除失败"),
    SYSTEM_MESSAGE_UNREAD_COUNT_ERROR(7005, "获取未读数量失败"),

    // 验证码错误 10000-10999
    INVALID_VERIFICATION_CODE(10001, "验证码错误或已过期"),
    SEND_VERIFICATION_CODE_ERROR(10002, "发送验证码失败"),
    INVALID_EMAIL_FORMAT(10003, "邮箱格式不正确"),
    EMAIL_NOT_EXIST(10004, "邮箱不存在"),
    ;

    private final int code;
    private final String message;

    ErrorCodeConstant(int code, String message) {
        this.code = code;
        this.message = message;
    }
}
